package com.easy.west.westclient.api.workplan.api;

import android.content.Context;
import android.support.annotation.NonNull;

import com.easy.west.westclient.api.base.bean.SuccessBean;
import com.easy.west.westclient.api.base.callback.BaseCallBack;
import com.easy.west.westclient.api.base.impl.BaseImpl;
import com.easy.west.westclient.api.workplan.baen.EventList;
import com.easy.west.westclient.api.workplan.event.GetAllEvent;
import com.easy.west.westclient.api.workplan.event.UploadPlanEvent;
import com.easy.west.westclient.util.UUIDGenerator;

/**
 * 工作计划
 * Created by xiatao on 2018/7/2.
 */

public class WorkPlanImpl extends BaseImpl<WorkPlanService> implements WorkPlanApi
{

    public WorkPlanImpl(@NonNull Context context) {
        super(context);
    }

    /**
     * 创建工作日程
     * @param uid 用户id
     * @param start_time 开始时间
     * @param end_time 结束时间
     * @param content 内容
     * @return 唯一识别码
     */
    @Override
    public String createWorkPlan(String start_time, String end_time, String content,String date,boolean top,long uid) {
        String  uuid = UUIDGenerator.getUUID();
        service.uploadWorkPlan(start_time,end_time,content,date,top,uid).enqueue(new BaseCallBack<SuccessBean>(new UploadPlanEvent(uuid)));
        return uuid;
    }

    /**
     * 查找所有日程
     * @param uid 用户id
     * @return 同上
     */
    @Override
    public String findAllPlan(long uid) {
        String  uuid = UUIDGenerator.getUUID();
        service.getAllEvents(uid).enqueue(new BaseCallBack<EventList>(new GetAllEvent(uuid)));
        return uuid;
    }

    /**
     *
     * @param start_time 开始时间
     * @param end_time 结束时间
     * @param content 内容
     * @param date
     * @param top
     * @param uid 用户id
     * @return
     */
    @Override
    public String changeWorkPlan(long id,String start_time, String end_time, String content, String date, boolean top, long uid) {
        String uuid = UUIDGenerator.getUUID();
        service.changeWorkPlan(id,start_time,end_time,content,date,top,uid).enqueue(new BaseCallBack<SuccessBean>(new UploadPlanEvent(uuid)));
        return uuid;
    }

    /**
     * 删除日程
     * @param pid
     * @return
     */
    @Override
    public String delete(long pid) {
        String uuid = UUIDGenerator.getUUID();
        service.delete(pid).enqueue(new BaseCallBack<SuccessBean>(new UploadPlanEvent(uuid)));
        return uuid;
    }
}
